package com.lelv.business.route.bo;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

import com.lelv.business.route.dao.IRouteDao;
import com.lelv.business.route.dao.IRoutePreDao;
import com.lelv.business.route.model.Route;
import com.lelv.business.route.model.RoutePre;
import com.lelv.framework.model.User;
import com.lelv.framework.plugin.DictUtil;
import com.lelv.framework.plugin.Page;

public class RouteBoImpl implements IRouteBo {

	private IRouteDao routeDao;
	private IRoutePreDao routePreDao;

	public IRouteDao getRouteDao() {
		return routeDao;
	}

	public void setRouteDao(IRouteDao routeDao) {
		this.routeDao = routeDao;
	}

	@Override
	public Page getRoutes(Page page) {
		// TODO Auto-generated method stub
		return this.routeDao.getRoutes(page);
	}

	@Override
	public void addRoute(Route rt) {
		// TODO Auto-generated method stub
		this.routeDao.addRoute(rt);
	}

	@Override
	public Route getRouteById(Long id) {
		// TODO Auto-generated method stub
		return this.routeDao.getRouteById(id);
	}

	@Override
	public List findRoutes(Route route) {
		// TODO Auto-generated method stub
		return this.routeDao.findRoutes(route);
	}

	@Override
	public List getRoutesByUser(User user) {
		// TODO Auto-generated method stub

		List<RoutePre> pres = this.routePreDao.getRoutePreByUid(user.getUserId());

		return pres;
	}

	public IRoutePreDao getRoutePreDao() {
		return routePreDao;
	}

	public void setRoutePreDao(IRoutePreDao routePreDao) {
		this.routePreDao = routePreDao;
	}

	@Override
	public Page getRoutes(Page page, Long creatorId) {
		// TODO Auto-generated method stub

		return this.routeDao.getRoutes(page, creatorId);
	}

	@Override
	public Page getRoutes(Page page, Long creatorId, Integer level) {
		// TODO Auto-generated method stub
		if(level < DictUtil.ADMIN_LEVEL_MAX){
			return this.routeDao.getRoutes(page, creatorId);
		}else{
			return this.routeDao.getRoutes(page);
		}
	}

	@Override
	public void deleteRoute(Long id) {
		// TODO Auto-generated method stub
		this.routeDao.deleteRoute(id);
	}

	@Override
	public void updateRoute(Route route) {
		// TODO Auto-generated method stub
		this.routeDao.updateRoute(route);
	}

}
